from time import sleep
from base.base import Base
import page


class PageAppParsing(Base):
    # 点击+
    def __page_app_click_plus(self):
        sleep(1)
        self.base_click(page.app_parsing_plus)

    # 点击创建
    def __page_app_click_create(self):
        sleep(1)
        self.base_click(page.app_parsing_create)

    # 输入框输入内容
    def __page_app_text_input(self, url):
        sleep(1)
        self.base_input(page.app_parsing_text, url)

    # 清空输入框文本
    def __page_app_text_clear(self):
        sleep(1)
        pass

    # 组合业务方法-解析
    def page_app_parsing(self, url):
        # 点击+
        self.__page_app_click_plus()
        # 输入框输入内容
        self.__page_app_text_input(url)
        # 点击创建
        self.__page_app_click_create()

    # 关闭弹窗
    def page_app_click_close(self):
        sleep(1)
        self.base_click(page.app_parsing_close)

    # 查找解析失败元素
    def page_fail_get_el(self):
        sleep(1)
        flag = False
        try:
            el = self.base_find(page.app_parsing_fail)
            if el:
                flag = True
        except Exception as e:
            return flag
        finally:
            return flag
